// https://leetcode.cn/problems/relative-ranks/
// Created by ade on 2022/8/9.
// 注意：所有得分都 互不相同
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <vector>

using namespace std;

class Solution {
public:
    vector <string> findRelativeRanks(vector<int> &score) {
        vector<int> cp = score;
        sort(cp.rbegin(), cp.rend());
        unordered_map<int, int> u;
        for (int i = 0; i < cp.size(); i++) {
            u[cp[i]] = i;
        }
        vector<string> m = {"Gold Medal", "Silver Medal", "Bronze Medal"};
        vector <string> res;
        for (auto i : score) {
            if (u[i] < 3) {
                res.push_back(m[u[i]]);
            } else {
                res.push_back(to_string(u[i] + 1));
            }
        }
        return res;
    }
};

int main() {
    Solution so;
    vector<int> nums = {5, 4, 3, 2, 1};
    auto res = so.findRelativeRanks(nums);
    for (auto i : res) {
        cout << i << ",";
    }
    cout << endl;
    return 0;
}